module ysyx_20220337_CPU (
    input           clk,
    input           rst,
    output  [31:0]  instr,
    output  [63:0]  pc_addr
);
    wire            branch;
    wire            jump;
    wire    [63:0]  imm;
    wire    [63:0]  dnpc;
    //wire    [63:0]  pc_addr;

    //wire    [31:0]  instr;
    wire    [63:0]  wb_data;
    wire    [2:0]   RW_type;
    wire            Mem_read;
    wire            Mem_write;
    wire    [4:0]   ALU_control;
    wire            op_dw;
    wire            Mem2Reg;
    wire    [63:0]  data1;
    wire    [63:0]  data2;
    wire    [63:0]  rs2_data;

    wire    [63:0]  ALU_result;

    wire    [63:0]  Read_data;

    ysyx_20220337_IFU ifu(
        .clk(clk),
        .rst(rst),
        .branch(branch),
        .dnpc(dnpc),
        .pc_addr(pc_addr)
    );

    ysyx_20220337_IDU idu(
        .clk(clk),
        .rst(rst),
        .instr(instr),
        .pc_addr(pc_addr),
        .wb_data(wb_data),
        .jump(jump),
        .RW_type(RW_type),
        .Mem_read(Mem_read),
        .Mem_write(Mem_write),
        .ALU_control(ALU_control),
        .op_dw(op_dw),
        .Mem2Reg(Mem2Reg),
        .data1(data1),
        .data2(data2),
        .rs2_data(rs2_data),
        .Imm(imm),
        .dnpc(dnpc)
    );

    ysyx_20220337_EXU exu(
        .ALU_control(ALU_control),
        .op_dw(op_dw),
        .data1(data1),
        .data2(data2),
        .jump(jump),
        .branch(branch),
        .ALU_result(ALU_result)
    );

    ysyx_20220337_MEMU memu(
        .clk(clk),

        //I Cache
        .pc(pc_addr),
        .instr(instr),
        //D Cache
        .RW_type(RW_type),
        .Mem_read(Mem_read),
        .Mem_write(Mem_write),
        .addr(ALU_result),
        .wdata(rs2_data),
        .Read_data(Read_data)
    );

    ysyx_20220337_WBU wbu(
        .Mem2Reg(Mem2Reg),
        .ALU_result(ALU_result),
        .Read_data(Read_data),
        .wb_data(wb_data)
    );

endmodule